package Day18;

import java.util.Scanner;
// 1:无需package
// 2: 类名必须Main, 不可修改

public class Main5 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        int t = scan.nextInt();
        int MOD = 998244353;
        while(t-- != 0){
          long n = scan.nextLong();
          long a = n % MOD;
          long b = (n + 1) % MOD;
          long c = (n + 2) % MOD;
          long product = a * b % MOD;
          product = product * c % MOD;
          long result = (a + product) % MOD;
          System.out.println(result);
        }
        scan.close();
    }
}